/**
 * Created by shanyun.gu on 2017/3/31.
 */
define(["ngApp", "angular"], function (ngApp, angular) {
    ngApp.directive("hasPermission", function (permissionFactory, $location) {
        return {
            restrict: 'A',
            link: function (scope, element, attr) {
                var path = $location.path();
                var permissionStr = attr.hasPermission.trim();
                var permissionFlag = permissionFactory.has(path, permissionStr);
                if (permissionFlag) {
                    element.attr("display","none");
                }
                else {
                    element.remove();
                }
            }
        }
    })
    //ngApp.directive("hasPermission", function () {
    //     return {
    //         restrict: 'A',
    //         link: function (scope, element, attr) {
    //             //var path = $location.path();
    //             // var permissionStr = attr.hasPermission.trim();
    //             // var permissionFlag = permissionFactory.has(path, permissionStr);
    //             // if (permissionFlag) {
    //             //     element.show();
    //             // }
    //             // else {
    //             //     element.hide();
    //             // }
    //             console.log(element)
    //         }
    //     }
    // })
});